
package cn.edu.scau.cmi.hombio.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.Calendar;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import org.codehaus.jackson.annotate.JsonIgnore;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllTaskIntervalCycles", query = "select myTaskIntervalCycle from TaskIntervalCycle myTaskIntervalCycle"),
		@NamedQuery(name = "findTaskIntervalCycleByCycleDays", query = "select myTaskIntervalCycle from TaskIntervalCycle myTaskIntervalCycle where myTaskIntervalCycle.cycleDays = ?1"),
		@NamedQuery(name = "findTaskIntervalCycleByFirstExecuteDate", query = "select myTaskIntervalCycle from TaskIntervalCycle myTaskIntervalCycle where myTaskIntervalCycle.firstExecuteDate = ?1"),
		@NamedQuery(name = "findTaskIntervalCycleById", query = "select myTaskIntervalCycle from TaskIntervalCycle myTaskIntervalCycle where myTaskIntervalCycle.id = ?1"),
		@NamedQuery(name = "findTaskIntervalCycleByMemo", query = "select myTaskIntervalCycle from TaskIntervalCycle myTaskIntervalCycle where myTaskIntervalCycle.memo = ?1"),
		@NamedQuery(name = "findTaskIntervalCycleByMemoContaining", query = "select myTaskIntervalCycle from TaskIntervalCycle myTaskIntervalCycle where myTaskIntervalCycle.memo like ?1"),
		@NamedQuery(name = "findTaskIntervalCycleByPrimaryKey", query = "select myTaskIntervalCycle from TaskIntervalCycle myTaskIntervalCycle where myTaskIntervalCycle.id = ?1") })

@Table(catalog = "pig", name = "task_interval_cycle")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "pigRs/cn/edu/scau/cmi/hombio/domain", name = "TaskIntervalCycle")

public class TaskIntervalCycle implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "Id", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@Id @GeneratedValue
	@XmlElement
	Integer id;
	/**
	* ����ĳѭ���״�ִ������
	* 
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "FirstExecuteDate", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	Calendar firstExecuteDate;
	/**
	* ����ѭ��������Ĭ��Ϊÿ�춼ִ��
	* 
	 */

	@Column(name = "CycleDays", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	Integer cycleDays;
	/**
	 */

	@Column(name = "Memo")
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String memo;

	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "TaskId", referencedColumnName = "Id", nullable = false) })
	@XmlTransient
	Task task;

	/**
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 */
	public Integer getId() {
		return this.id;
	}

	/**
	* ����ĳѭ���״�ִ������
	* 
	 */
	public void setFirstExecuteDate(Calendar firstExecuteDate) {
		this.firstExecuteDate = firstExecuteDate;
	}

	/**
	* ����ĳѭ���״�ִ������
	* 
	 */
	public Calendar getFirstExecuteDate() {
		return this.firstExecuteDate;
	}

	/**
	* ����ѭ��������Ĭ��Ϊÿ�춼ִ��
	* 
	 */
	public void setCycleDays(Integer cycleDays) {
		this.cycleDays = cycleDays;
	}

	/**
	* ����ѭ��������Ĭ��Ϊÿ�춼ִ��
	* 
	 */
	public Integer getCycleDays() {
		return this.cycleDays;
	}

	/**
	 */
	public void setMemo(String memo) {
		this.memo = memo;
	}

	/**
	 */
	public String getMemo() {
		return this.memo;
	}

	/**
	 */
	public void setTask(Task task) {
		this.task = task;
	}

	/**
	 */
	@JsonIgnore
	public Task getTask() {
		return task;
	}

	/**
	 */
	public TaskIntervalCycle() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(TaskIntervalCycle that) {
		setId(that.getId());
		setFirstExecuteDate(that.getFirstExecuteDate());
		setCycleDays(that.getCycleDays());
		setMemo(that.getMemo());
		setTask(that.getTask());
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("id=[").append(id).append("] ");
		buffer.append("firstExecuteDate=[").append(firstExecuteDate).append("] ");
		buffer.append("cycleDays=[").append(cycleDays).append("] ");
		buffer.append("memo=[").append(memo).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof TaskIntervalCycle))
			return false;
		TaskIntervalCycle equalCheck = (TaskIntervalCycle) obj;
		if ((id == null && equalCheck.id != null) || (id != null && equalCheck.id == null))
			return false;
		if (id != null && !id.equals(equalCheck.id))
			return false;
		return true;
	}
}
